MBR
Smallest rectangle that fully encloses a region of interest, providing a bounding box with minimal area.
🎭 Mask options and parameters of getMbr
method
🔎 ROI options and parameters of mbr
accessor
Minimum Bounding Rectangle(MBR) is the smallest rectangle which can fit the region of interest in question.
MBR is relevant for such things as extracting features, detecting collisions or simply localizing objects.
In ImageJS minimum bounding rectangle is a ROI class accessor that returns a Mbr
object.
Property name | Description | Property type |
---|---|---|
points | points that form MBR | Point[] |
perimeter | MBR's perimeter | number |
surface | MBR's surface | number |
height | MBR's height | number |
width | MBR's width | number |
angle | MBR's angle | number |
aspectRatio | ratio between MBR's width and height | number |
const mbr = roi.mbr;
It can also be a Mask method to calculate its mbr:
const mbr = mask.getMbr();
Implementation
Here's how Minimum Bounding Rectangle is calculated in ImageJS:
Finding convex hull:an algorithm is based on the fact that one of the MBR sides is aligned with one of the convex hull sides.
Rotating an object: an object gets rotated parallel to the X-axis. It allows finding tilt angles of the diameters. It also facilitates calculation of the points. After all the data is found, it just gets rotated back by the same angle to get actual result.
Finding extremities: since the object is rotated, it means that vertical lines will be perpendicular to the hull side in question. Therefore, for each side, algorithm finds extremities which in turn calculate into points, width and surface.